<?php
/**
 * Created by PhpStorm.
 * User: dell
 * Date: 2017/6/9
 * Time: 10:25
 */

namespace Home\Model;

use Think\Model;
use WeiChat\api\WeixinApi;

class UserModel extends Model{
    protected $tableName = "user";

    public function addWeiChatUser($data){
        $openid = $data['openid'];
        if($this->where("openid = '%s'",$openid)->find()){
            return true;
        }else{
            $res = WeixinApi::getInstance()->getUserInfo();
            $res = $this->add($res);
            return $res;
        }
    }
}